package com.cyandpos.pad.posdata;


import com.cyandpos.pad.utils.MoneyUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2020/2/21.
 */

public class SubTicketItem implements Serializable {
    private String tcktInx;//订单查询返回的子小票序号
    private String subInx;//子小票序号
    private Person personInfo;//营业员信息
    private String deptCode;//部门代码
    private List<Goods> goodsList;//商品列表

    public String getDeptCode() {
        return deptCode;
    }

    public void setDeptCode(String deptCode) {
        this.deptCode = deptCode;
    }

    public String getTcktInx() {
        return tcktInx;
    }

    public void setTcktInx(String tcktInx) {
        this.tcktInx = tcktInx;
    }

    public SubTicketItem() {
        goodsList = new ArrayList<>();
    }

    public String getSubInx() {
        return subInx;
    }

    public void setSubInx(String subInx) {
        this.subInx = subInx;
    }

    public Person getPersonInfo() {
        return personInfo;
    }

    public void setPersonInfo(Person personInfo) {
        this.personInfo = personInfo;
    }

//    public String getDeptCode() {
//        return deptCode;
//    }
//
//    public void setDeptCode(String deptCode) {
//        this.deptCode = deptCode;
//    }

    public List<Goods> getGoodsList() {
        return goodsList;
    }

    public void setGoodsList(List<Goods> goodsList) {
        this.goodsList = goodsList;
    }

    /**
     * 小票商品总金额
     * @return
     */
    public int getTotalMoney(){
        int sumMoney = 0;
        for(Goods g:goodsList){
            sumMoney+= MoneyUtils.getMoneyInt(g.getSaleMoney());
        }
        return sumMoney;
    }

    /**
     * 总数量
     * @return
     */
    public double getTotalCount(){
        double sumCount = 0;
        for(Goods g:goodsList){
            sumCount+= MoneyUtils.getStrToDouble(g.getSaleCount());
        }
        return sumCount;
    }

    /**
     * 总折扣
     * @return
     */
    public int getTotalDiscount(){
        int sumDiscount = 0;
        for(Goods g:goodsList){
            sumDiscount+= MoneyUtils.getMoneyInt(g.getDiscount());
        }
        return sumDiscount;
    }

    @Override
    public String toString() {
        return "SubTicketItem{" +
                "subInx='" + subInx + '\'' +
                ", personInfo=" + personInfo +
//                ", deptCode='" + deptCode + '\'' +
                ", goodsList=" + goodsList +
                '}';
    }
}
